package com.flick.shopSales.ctrl;

import com.flick.baseCtrl.BaseCtrl;
import com.flick.common.Filters;
import com.flick.common.PageParam;
import com.flick.common.Rule;
import com.flick.shopSales.service.ShopSalesServ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.ArrayList;

/**
 * Created by flick on 2017/4/23.
 */
@RestController
@EnableAutoConfiguration
@ResponseBody
@CrossOrigin
@RequestMapping("/api/v1/shopSales")
public class ShopSalesCtrl extends BaseCtrl<ShopSalesServ>{

    @RequestMapping("/down")
    public ResponseEntity<byte[]> downloadExcel() throws IOException {
        return serv.downloadExcel();
    }

//    @Autowired
//    ShopSalesServ shopSalesServ;
//
//    /**
//     * 查看所有商品类型列表
//     * @return
//     */
//    @RequestMapping(method = RequestMethod.GET)
//    public Object list(){
//        return shopSalesServ.list();
//    }
//
//    /**
//     * 查看商品分类列表（带分页）
//     * @param rows 页码
//     * @param page 每页大小
//     * @return
//     */
//    @RequestMapping(params = {"page","rows"},method = RequestMethod.GET)
//    public Object page(@RequestParam Integer page,@RequestParam Integer rows,
//                       @RequestParam(required = false) String sidx,@RequestParam(required = false) String sord,
//                       @RequestParam(required = false) String searchField,@RequestParam(required = false) String searchString,
//                       @RequestParam(required = false) String searchOper){
//        PageParam pageParam = new PageParam();
//        pageParam.setPageNum(page);
//        pageParam.setPageSize(rows);
//        pageParam.setSidx(sidx);
//        pageParam.setSord(sord);
//        Filters filters = new Filters();
//        filters.setGroupOp("and");
//        ArrayList<Rule> rules = new ArrayList<>();
//        Rule rule = new Rule();
//        rule.setField(searchField);
//        rule.setData(searchString);
//        rule.setOp(searchOper);
//        rules.add(rule);
//        filters.setRules(rules);
//        pageParam.setFilters(filters);
//        return shopSalesServ.page(pageParam);
//    }
//
//    /**
//     * 根据ID查看商品分类
//     * @param id 商品ID
//     * @return
//     */
//    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
//    public Object get(@PathVariable String id){
//        return shopSalesServ.get(id);
//    }
}
